//
//  I_Member.m
//  YunDongAdmin
//
//  Created by lqq on 2018/9/7.
//  Copyright © 2018年 cloudfighting.com. All rights reserved.
//

#import "I_Member.h"

@implementation I_Member


/**
 请求会员列表
 */
+ (NetworkTask *)requestMemberListOnSuccess:(void(^)(NSMutableArray *list))successBlock failure:(ErrorBlock)failureBlock
{
    return [NET POST:@"/gym-api/admin/1.0.0/getMemberList" parameters:nil criticalValue:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull resultObject) {
        NSMutableArray *list = [M_Member arrayOfModelsFromDictionaries:SAFE_VALUE_FOR_KEY(resultObject, @"data") error:nil];
        if (successBlock) {
            successBlock(list);
        }
    } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
        }
    }];
}

/**
 请求会员详情
 */
+ (NetworkTask *)requestMemberDetailWithMemberId:(NSString *)memberId
                                         success:(void(^)(M_MemberDetail *memberDetail))successBlock
                                         failure:(ErrorBlock)failureBlock
{
    return [NET POST:@"/gym-api/admin/1.0.0/getMemberDetail" parameters:@{@"memberId":SAFE_NIL_STRING(memberId)} criticalValue:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull resultObject) {
        if (successBlock) {
            M_MemberDetail *detail = [[M_MemberDetail alloc] initWithDictionary:SAFE_VALUE_FOR_KEY(resultObject, @"data") error:nil];
            successBlock(detail);
        }
    } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
        }
    }];
}


/**
 排课的会员列表
 
 @param dateInt 20180909
 @param timeInt 800
 */
+ (NetworkTask *)requestSchduleMemberListByDateInt:(NSInteger)dateInt
                                           timeInt:(NSInteger)timeInt
                                           success:(void(^)(NSMutableArray *list))successBlock failure:(ErrorBlock)failureBlock
{
    return [NET POST:@"/gym-api/admin/1.0.0/listScheduleMemberV2" parameters:@{@"dateInt":@(dateInt),@"timeInt":@(timeInt)} criticalValue:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull resultObject) {
        if (successBlock) {
            NSArray *resultArr = SAFE_VALUE_FOR_KEY(resultObject, @"data");
            NSMutableArray *list = [M_ScheduleMemberDTO arrayOfModelsFromDictionaries:resultArr error:nil];
            successBlock(list);
            
        }
    } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
        }
    }];
}
@end
